<div class="container mt-5">
    <div class="card">
        <div class="card-header bg-transparent">
            贴子管理
        </div>
        <div class="card-body">
            <x-form title="贴子标题" name="title" value="{{old('title',$topic->title)}}" required></x-form>
            @foreach($tags as $tag)
                <label>
                    <input type="checkbox" name="tags[]" class="d-inline-block mr-1"
                           value="{{$tag['id']}}" {{$topic->tags->contains($tag['id']) ? 'checked' : ''}}
                        {{collect(old('tags'))->contains($tag['id']) ? 'checked' :''}}>{{$tag['title']}}
                </label>
            @endforeach

            <div id="app">
                <editor name="content"  error="@error('content') {{$message}} @enderror" :content="content" ></editor>
            </div>
        </div>
        <div class="card-footer text-muted bg-transparent">
            <button class="btn btn-primary">保存</button>
        </div>
    </div>
</div>
@push('scripts')
    <script>
        window.vue={
            data:{
                content:@json(old('content',$topic->content))
            }
        }
    </script>
@endpush
